package edu.pku.sei.transformation.editor.views.figures;

import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;

public class ConstraintFigure extends BentCornerFigure{
	private TextArea text = new TextArea();
	private Label head = new Label("<<Constraint>>");
	private final static int HEAD_HEIGHT = 10;

	public ConstraintFigure() {
		this.setLayoutManager(new XYLayout());
		head.setFont(FontConstant.STEREO_TYPE_LABEL);
		this.add(head);
		this.add(text);
		text.setBorder(new MarginBorder(5));
	}

	public void setText(String s) {
		text.setText(s);
	}
	
	public void setHead(String s) {
		head.setText(s);
	}
	
	@Override
	public void setBounds(Rectangle rect) {
		super.setBounds(rect);
		
		head.setLocation(rect.getLocation());
		head.setSize(rect.width, HEAD_HEIGHT);
		
		text.setLocation(new Point(rect.x, rect.y+HEAD_HEIGHT));
		text.setSize(rect.width, rect.height - HEAD_HEIGHT);
	}
}
